﻿<?php 
if(isset($_SESSION['config_template']))
{
	if($_SESSION['config_template']=='layoutmain_web1')
	{
		?>
			<?php if((isset($products) && count($products)!= 0) || (isset($newsR)&& count($newsR)!= 0) || (isset($QAs)&& count($QAs)!= 0) ){?>
			<link rel="stylesheet" type="text/css" href="/css/web1/relative_news.css" />
			<link rel="stylesheet" type="text/css" href="/css/web1/relative_product.css" />
				<div class="page-title">
					<h1><?php echo $title;?><?php if(isset($permission) && $permission=="true") {?>
								<!-- Tạo cây bút chì cho click and change -->
								<div style="float:right;">
									<ul class="gallery clearfix">
										<a href="/relative/clickchange?type=1&iframe=true&width=370&height=205" rel="prettyPhoto[iframe]">
											<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-left:25px; margin-top:0px;"></img>
										</a>
									</ul>
								<div style="float:right;">
								<!-- End - Tạo cây bút chì cho click and change -->
							<?php  }?></h1>
				</div>
				<?php $util= new Util();?>
				<?php  if(isset($products)){?>
					<div style="margin:0px;padding:0px" class="fieldset">
					<div id="relative_product">
					<?php foreach ($products as $product){?>
					
						<div class="relative_content">
							
										<div class="product_img">
											<center><img width="130" height="130" id="product_image" alt="" src="<?php echo $product["avatar"]?>"></center>
										</div>
										<div class="product_name">
											<a id="product_name_link" href="/index/detail?id=<?php echo $product["thing_id"];?>"><?php echo $product["title"]?></a>
										</div>
										<div class="product_price">
											<p id="product_price_p"> <?php if($product["price"]!="") {echo number_format($product["price"]); }else {echo"Chưa có giá";}?> VNĐ</p>
										</div>
									
							</div>
					<?php } ?> 
						</div>
					</div>
					<div style="clear:both;"></div>
				<?php } else if (isset($newsR)){ ?>
				
						<div style="margin:0px;padding:0px" class="fieldset">
							<div id="relative_news">
							<?php foreach ($newsR as $news){ 	$title_news=strlen($news["title"]);
								$des_news=strlen($news["title"]);?>
								<div class="relative_content">
											<img alt="news" src="<?php echo $news["avatar"]?>" id="news_img" class="news_img">
											<a class="news_link_a" href="/news/detail?id=<?php echo $news["thing_id"];?>"><?php if($title_news<=15)echo $news["title"];else echo substr($news["title"],0 ,15)."..."?></a>
											<p><span>(</span><span id="news_date_span"><?php echo $util->makeDays($news["update_date"])?></span><span>)</span></p>
											<p id="news_intro" class="news_intro"><?php if($des_news<=30)echo $news["short_description"];else echo substr($news["short_description"],0 ,30)."..."?></p>
											<a class="floatright" href=""><?php echo $textMore?>...</a>
								</div>
								<?php } ?>
							</div>
						</div>
						<div style="clear:both;"></div>
				<?php } else { ?>
					<div style="margin:0px;padding:0px" class="fieldset">
						<div id="relative_aq">
						<?php foreach ($QAs as $QA){$title_QA=strlen($news["title"]); ?>
							<div class="relative_content">
										<div class="aq_link">
											<a id="aq_link_a" href="/qa/detail?id=<?php echo $QA["thing_id"];?>"><?php if($title_QA<=50)echo $QA["title"];else echo substr($QA["title"],0 ,50)."..."?></a>
										</div>
										<div class="aq_date">
											<span id="aq_date_span"><?php echo $util->makeDays($QA["update_date"])?></span>
										</div>
							</div>
							<?php } ?>
						</div>
					</div>
					<div style="clear:both;"></div>
				<?php }}?>
		
		
	<?php 
	}
	else 
	{
		if($_SESSION['config_template']=='layoutmain_web2')
		{?>
			<?php if((isset($products) && count($products)!= 0) || (isset($newsR)&& count($newsR)!= 0) || (isset($QAs)&& count($QAs)!= 0) ){?>
				<?php $util= new Util();?>
				<?php  if(isset($products)){?>
					<!--relative-->
					<div class="page-title">
					    <h1><span style="color: #EA2E9D;font-size: 24px;"><?php echo $title;?></span>
							<?php if(isset($permission) && $permission=="true") {?>
								<!-- Tạo cây bút chì cho click and change -->
								<div style="float:right;">
									<ul class="gallery clearfix">
										<a href="/relative/clickchange?type=1&iframe=true&width=370&height=205" rel="prettyPhoto[iframe]">
											<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-left:25px; margin-top:0px;"></img>
										</a>
									</ul>
								<div style="float:right;">
								<!-- End - Tạo cây bút chì cho click and change -->
							<?php  }?>					    
					    </h1>
					</div>
					<?php $total = count($products);?>
					<div class="collateral-box up-sell">
					    <table cellspacing="0" id="upsell-product-table" class="generic-product-grid catalog-listing">
					        <tbody>
					        <?php for($i = 0; $i < $total;$i++){?>
								<tr class="first odd">
									<?php for($j =$i ;$j < $i+4 ;$j++){?>
									<?php if(isset($products[$j])){$product = $products[$j];?>
					                <td>
										<h5><a href="/index/detail?id=<?php echo $product["thing_id"];?>"><?php echo $product["title"]?></a></h5>
										<p class="product-image"><a href="/index/detail?id=<?php echo $product["thing_id"];?>"><img height="125" width="125" alt="><?php echo $product["title"]?>" src="<?php echo $product["avatar"]?>" id="product_image"></a></p>
					                    
										<div class="price-box" style="text-align:center;">
					                        <span id="product-minimal-price-54" class="price"> <?php if($product["price"]!="") echo number_format($product["price"]); else echo"Chưa có giá";?> VNĐ</span>
					                    </div>   
									</td>
									<?php }else{?>
										<td class="empty-product">&nbsp;</td>
									<?php }?>
									<?php }?>
					            </tr>
								
								<?php $i = $j;}?>
					        </tbody>
						</table>
					    <script type="text/javascript">decorateTable('upsell-product-table')</script>
					</div>
					<!-- end relative -->				
					<?php  } // end product?>
					
					<?php  if(isset($newsR)){ ?>
					<link rel="stylesheet" type="text/css" href="/css/relative_news.css" />
							<div class="page-title">
							    <h1><span style="color: #EA2E9D;font-size: 24px;"><?php echo $title;?></span>
									<?php if(isset($permission) && $permission=="true") {?>
										<!-- Tạo cây bút chì cho click and change -->
										<div style="float:right;">
											<ul class="gallery clearfix">
												<a href="/relative/clickchange?type=2&iframe=true&width=370&height=205" rel="prettyPhoto[iframe]">
													<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-left:25px; margin-top:0px;"></img>
												</a>
											</ul>
										<div style="float:right;">
										<!-- End - Tạo cây bút chì cho click and change -->
									<?php  }?>					    
							    </h1>
							</div>
												
							<div id="relative_news">
								<!--repeated content-->
								<?php foreach ($newsR as $news){ 	$title_news=strlen($news["title"]);
								$des_news=strlen($news["title"]);?>
							
								<div class="relative_content">
									<img class="news_img" id="news_img" src="<?php echo $news["avatar"]?>" alt="news" />
									<a href="/news/detail?id=<?php echo $news["thing_id"];?>" id="news_link_a"><?php if($title_news<=15)echo $news["title"];else echo substr($news["title"],0 ,15)."..."?></a>
									<p><span>(</span><span id="news_date_span"><?php echo $util->makeDays($news["update_date"])?></span><span>)</span></p>
									<p class="news_intro" id="news_intro"><?php if($des_news<=30)echo $news["short_description"];else echo substr($news["short_description"],0 ,30)."..."?></p>
									<a href="/news/detail?id=<?php echo $news["thing_id"];?>" class="find_out_more"><?php echo $textMore?>.</a>
								</div>
								<?php } //end for of news?>
								</div>
					<?php }// end news?>
					
				<?php  if(isset($QAs)){ ?>
				<link rel="stylesheet" type="text/css" href="/css/web2/relative_faq.css" />
							<div class="page-title">
							    <h1><span style="color: #EA2E9D;font-size: 24px;"><?php echo $title;?></span>
									<?php if(isset($permission) && $permission=="true") {?>
										<!-- Tạo cây bút chì cho click and change -->
										<div style="float:right;">
											<ul class="gallery clearfix">
												<a href="/relative/clickchange?type=3&iframe=true&width=370&height=205" rel="prettyPhoto[iframe]">
													<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-left:25px; margin-top:0px;"></img>
												</a>
											</ul>
										<div style="float:right;">
										<!-- End - Tạo cây bút chì cho click and change -->
									<?php  }?>					    
							    </h1>
							</div>				
						<div id="relative_aq">
								<?php foreach ($QAs as $QA){$title_QA=strlen($news["title"]); ?>
								<!--repeated content-->
								<div class="relative_content">
									<div class="aq_link">
										<a href="/qa/detail?id=<?php echo $QA["thing_id"];?>" id="aq_link_a" ><?php if($title_QA<=50)echo $QA["title"];else echo substr($QA["title"],0 ,50)."..."?></a>
									</div>
									<div class="aq_date">
										<span id="aq_date_span" ><?php echo $util->makeDays($QA["update_date"])?></span>
									</div>
								</div>
								<?php  } // end for of QA?>
						</div>
				<?php }// ned QA?>
				<br />
					
				<?php }else{ ?>
							<div class="page-title">
							    <h1><span style="color: #EA2E9D;font-size: 24px;"><?php echo $title;?></span>
									<?php if(isset($permission) && $permission=="true") {?>
										<!-- Tạo cây bút chì cho click and change -->
										<div style="float:right;">
											<ul class="gallery clearfix">
												<a href="/relative/clickchange?type=<?php echo $rtype ?>&iframe=true&width=370&height=205" rel="prettyPhoto[iframe]">
													<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-left:25px; margin-top:0px;"></img>
												</a>
											</ul>
										<div style="float:right;">
										<!-- End - Tạo cây bút chì cho click and change -->
									<?php  }?>					    
							    </h1>
							</div>				
					<div style="clear:both;"></div>	
					<div style="text-align: center;"><span ><?php echo $textNoInfo?></span></div>
				<?php }?>		
		
	<?php }
		else 
	{?>			
<link rel="stylesheet" type="text/css" href="/css/relative_faq.css" />
<link rel="stylesheet" type="text/css" href="/css/btn_all.css" />
<link rel="stylesheet" type="text/css" href="/css/relative_news.css" />
<link rel="stylesheet" type="text/css" href="/css/relative_product.css" />
	
<?php if((isset($products) && count($products)!= 0) || (isset($newsR)&& count($newsR)!= 0) || (isset($QAs)&& count($QAs)!= 0) ){?>
	<?php $util= new Util();?>
	<?php  if(isset($products)){?>
		<div id="relative_product">
					<div>
						<p ><?php echo $title?></p>
						<?php if(isset($permission) && $permission=="true") {?>
						<!-- Tạo cây bút chì cho click and change -->
						<ul class="gallery clearfix">
							<a href="/relative/clickchange?type=1&iframe=true&width=370&height=205" rel="prettyPhoto[iframe]">
								<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-left:25px; margin-top:0px;"></img>
							</a>
						</ul>
						<!-- End - Tạo cây bút chì cho click and change -->
						<?php  }?>
						<div class="line"><hr></div>
					</div>
					<!--repeated content-->
					<?php foreach ($products as $product){?>
					<div class="relative_content">
						<div class="product_img">
							<img src="<?php echo $product["avatar"]?>" alt="" width="130" height="130" id="product_image"/>
						</div>
						<div class="product_name">
							<a href="/index/detail?id=<?php echo $product["thing_id"];?>" id="product_name_link"><?php echo $product["title"]?></a>
						</div>
						<div class="product_price">
							<p id="product_price_p"> <?php if($product["price"]!="") echo number_format($product["price"]); else echo"Chưa có giá";?> VNĐ</p>
						</div>
					</div>
					<?php }// end for of product?>
		</div>
		<?php  } // end product?>
		
		<?php  if(isset($newsR)){ ?>
				<div id="relative_news">
					<div>
						<p ><?php echo $title?></p>
							<?php if(isset($permission) && $permission=="true") {?>
						<!-- Tạo cây bút chì cho click and change -->
						<ul class="gallery clearfix">
							<a href="/relative/clickchange?type=2&iframe=true&width=370&height=205" rel="prettyPhoto[iframe]">
								<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-left:25px; margin-top:0px;"></img>
							</a>
						</ul>
						<!-- End - Tạo cây bút chì cho click and change -->
						<?php  }?>
						<div class="line"><hr></div>
					</div>
					<!--repeated content-->
					<?php foreach ($newsR as $news){ 	$title_news=strlen($news["title"]);
					$des_news=strlen($news["title"]);?>
				
					<div class="relative_content">
						<img class="news_img" id="news_img" src="<?php echo $news["avatar"]?>" alt="news" />
						<a href="/news/detail?id=<?php echo $news["thing_id"];?>" id="news_link_a"><?php if($title_news<=15)echo $news["title"];else echo substr($news["title"],0 ,15)."..."?></a>
						<p><span>(</span><span id="news_date_span"><?php echo $util->makeDays($news["update_date"])?></span><span>)</span></p><br/>
						<p class="news_intro" id="news_intro"><?php if($des_news<=30)echo $news["short_description"];else echo substr($news["short_description"],0 ,30)."..."?></p><br/>
						<br/>
						<a href="/news/detail?id=<?php echo $news["thing_id"];?>" class="find_out_more"><?php echo $textMore?>.</a>
					</div>
					<?php } //end for of news?>
					</div>
		<?php }// end news?>
		
	<?php  if(isset($QAs)){ ?>
			<div id="relative_aq">
					<div>
						<p ><?php echo $title?></p>
							<?php if(isset($permission) && $permission=="true") {?>
						<!-- Tạo cây bút chì cho click and change -->
						<ul class="gallery clearfix">
							<a href="/relative/clickchange?type=3&iframe=true&width=370&height=205" rel="prettyPhoto[iframe]">
								<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-left:25px; margin-top:0px;"></img>
							</a>
						</ul>
						<!-- End - Tạo cây bút chì cho click and change -->
						<?php }?>
						<div class="line"><hr></div>
					</div>
					<?php foreach ($QAs as $QA){$title_QA=strlen($news["title"]); ?>
					<!--repeated content-->
					<div class="relative_content">
						<div class="aq_link">
							<a href="/qa/detail?id=<?php echo $QA["thing_id"];?>" id="aq_link_a"><?php if($title_QA<=50)echo $QA["title"];else echo substr($QA["title"],0 ,50)."..."?></a>
						</div>
						<div class="aq_date">
							<span id="aq_date_span"><?php echo $util->makeDays($QA["update_date"])?></span>
						</div>
					</div>
					<?php  } // end for of QA?>
			</div>
	<?php }// ned QA?>
	<br />
		
	<?php }else{ ?>
		<div style="clear:both">
		<p><?php echo $title?><p>
		<?php if(isset($permission) && $permission=="true") {?>
		<!-- Tạo cây bút chì cho click and change -->
		<ul class="gallery clearfix">
			<a href="/relative/clickchange?type=<?php echo $rtype ?>&iframe=true&width=370&height=205" rel="prettyPhoto[iframe]">
				<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-left:25px; margin-top:0px;"></img>
			</a>
		</ul>
		<!-- End - Tạo cây bút chì cho click and change -->
		<?php }?>
		</div>
		<div class="line"><hr></div>
		<div style="clear:both;"></div>	
		<div style="text-align: center;"><span ><?php echo $textNoInfo?></span></div>
	<?php }?>
<?php }
	}
}?>	
	<div style="clear:both;"></div>	